cmake_minimum_required(VERSION 3.5)

include(cmake/utils.cmake)

qcustomplot_extract_version()

project(qcustomplot VERSION ${QCUSTOMPLOT_VERSION} LANGUAGES CXX)

message(STATUS "{qcustomplot}: ${QCUSTOMPLOT_VERSION}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport)

set(PROJECT_SOURCES
    qcustomplot/qcustomplot.h
    qcustomplot/qcustomplot.cpp
)

add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport)
